﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DRHotel_v1.Classes;
using DRHotel_v1.Classes.DBManagers;

namespace DRHotel_v1.HousekeepingAndStaffMngmt
{
    public partial class RoomManagementRetrievedFeedback : Form
    {
        public RoomManagementRetrievedFeedback(string Type, string Value)
        {
            InitializeComponent();

            //Defining what the user search by and get the results
            if (Type.Equals("Room ID"))
            {
                int value2 = Convert.ToInt32(Value);
                ArrayList roomList = HousekeepingDBManager.GetRoomListByRoomID(value2);

                int counter = 0;
                foreach (Room room in roomList)
                {
                    this.dgvResult.Rows.Add(new DataGridViewRowCollection(this.dgvResult));
                    this.dgvResult.Rows[counter].SetValues(room.roomID, room.roomType, room.bedType, room.capacity, room.roomRates, room.roomStatus, room.remark, room.smoking);
                    counter++;
                }
            }
            else if (Type.Equals("Room Type"))
            {
                ArrayList roomList = HousekeepingDBManager.GetAllRoomListByRoomType(Value);

                int counter = 0;
                foreach (Room room in roomList)
                {
                    this.dgvResult.Rows.Add(new DataGridViewRowCollection(this.dgvResult));
                    this.dgvResult.Rows[counter].SetValues(room.roomID, room.roomType, room.bedType, room.capacity, room.roomRates, room.roomStatus, room.remark, room.smoking);
                    counter++;
                }
            }
            else if (Type.Equals("Room Bed Type"))
            {
                if (Value.Equals("Double Single"))
                {
                    Value = "Double";
                }

                ArrayList roomList = HousekeepingDBManager.GetAllRoomListByBedType(Value);

                int counter = 0;
                foreach (Room room in roomList)
                {
                    this.dgvResult.Rows.Add(new DataGridViewRowCollection(this.dgvResult));
                    this.dgvResult.Rows[counter].SetValues(room.roomID, room.roomType, room.bedType, room.capacity, room.roomRates, room.roomStatus, room.remark, room.smoking);
                    counter++;
                }
            }
            else if (Type.Equals("Room Status"))
            {
                ArrayList roomList = HousekeepingDBManager.GetAllRoomListByRoomStatus(Value);

                int counter = 0;
                foreach (Room room in roomList)
                {
                    this.dgvResult.Rows.Add(new DataGridViewRowCollection(this.dgvResult));
                    this.dgvResult.Rows[counter].SetValues(room.roomID, room.roomType, room.bedType, room.capacity, room.roomRates, room.roomStatus, room.remark, room.smoking);
                    counter++;
                }
            }
            else if (Type.Equals("Room Smoking"))
            {
                string smoking = "0";

                if (Value.Equals("Yes"))
                {
                    smoking = "1";
                }
                else if (Value.Equals("No"))
                {
                    smoking = "0";
                }

                ArrayList roomList = HousekeepingDBManager.GetAllRoomListBySmoking(smoking);

                int counter = 0;
                foreach (Room room in roomList)
                {
                    this.dgvResult.Rows.Add(new DataGridViewRowCollection(this.dgvResult));
                    this.dgvResult.Rows[counter].SetValues(room.roomID, room.roomType, room.bedType, room.capacity, room.roomRates, room.roomStatus, room.remark, room.smoking);
                    counter++;
                }
            }
            else if (Type.Equals("All"))
            {
                ArrayList roomList = HousekeepingDBManager.GetAllRoomList();

                int counter = 0;
                foreach (Room room in roomList)
                {
                    this.dgvResult.Rows.Add(new DataGridViewRowCollection(this.dgvResult));
                    this.dgvResult.Rows[counter].SetValues(room.roomID, room.roomType, room.bedType, room.capacity, room.roomRates, room.roomStatus, room.remark, room.smoking);
                    counter++;
                }
            }
        }
    }
}
